<template>
	<view class="contain">
		<view class="tables" style="margin-top:10px;">
			<u-row customStyle="margin-bottom: 10px">
				<u-col span="3" justify="center" align="center" textAlign="center">
					<view class="mid blod">课程</view>
				</u-col>
				<u-col span="3" justify="center" align="center" textAlign="center">
					<view class="mid blod">姓名</view>
				</u-col>
				<u-col span="3" justify="center" align="center" textAlign="center">
					<view class="mid blod">年龄</view>
				</u-col>
				<u-col span="3" justify="center" align="center" textAlign="center">
					<view class="mid blod">状态</view>
				</u-col>
			</u-row>
		</view>
		<view class="tables" style="margin-top:10px;border-bottom:0px;" v-for="item in SubScribes.data">
			<u-row customStyle="margin-bottom: 10px">
				<u-col span="3" justify="center" align="center" textAlign="center">
					<view class="small">{{item.coursename}}</view>
				</u-col>
				<u-col span="3" justify="center" align="center" textAlign="center">
					<view class="small">{{item.studentname}}</view>
				</u-col>
				<u-col span="3" justify="center" align="center" textAlign="center">
					<view class="small">{{item.studentage}}</view>
				</u-col>
				<u-col span="3" justify="center" align="center" textAlign="center">
					<view class="small" style="color:#00a100;">{{item.cstatus}}</view>
				</u-col>
			</u-row>
		</view>
	</view>
</template>

<script setup lang='ts'>
import { ref,reactive } from 'vue'
import { onLoad,onShow } from '@dcloudio/uni-app'
import { userStore } from '@/stores/userStore'
let store = userStore();	
let { hasLogin,userData } = userStore();

let SubScribes=reactive({data:[]});
let isLoad=ref(false);

/* 获取订阅 */
const getSubScribes=()=>{
	let paraData={
		userid:userData.userinfo.id
	};
	uni.$tools.Reqeust('/api/getSubScribes',paraData,'POST').then((res:any)=>{
			console.log('获取订阅结果:',res);
			if (res.data.code == 200) {
				SubScribes.data=res.data.subscribesList;
			}else{
				uni.$tools.Toast(res.data.msg);
			}
	})	
}

onLoad(()=>{
	if(!hasLogin){
		uni.$tools.Toast("请登录");
		setTimeout(()=>{
			uni.$tools.GoUrl("/pages/login/login");
		},1200);
	}else{
		getSubScribes();
		isLoad.value=true;
	}
});

onShow(()=>{
	if(!isLoad.value){
		if(uni.getStorageSync("token") && uni.getStorageSync("token")!=''){
			getSubScribes();
		}		
	}
})

</script>

<style lang='scss' scoped>
	@import "subscribes.scss";
</style>